home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’92 / Text Capture FKEY / Begin_copy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-05  |  1.5 KB  |  62 lines  |  [TEXT/KAHL]

  1. #include "defs.h"
  2.  
  3. #define        CHECKPOINTS        0
  4. #include "debug.h"
  5.  
  6. void Begin_copy( void )
  7. {
  8.     Rect    dest, view;
  9.     GrafPtr    save_port;
  10.     
  11.     CKPT("Begin_copy start");
  12.     /*
  13.         Since this text isn't actually going to be displayed, it doesn't
  14.         matter much what view and destination rectangles we use.
  15.     */
  16.     dest.top = 10000;
  17.     dest.bottom = 20000;
  18.     dest.left = 0;
  19.     dest.right = 1000;
  20.     view = dest;
  21.     /*
  22.         If we used the front window's port as the TextEdit port, then
  23.         the TEKey and TEInsert calls in My_StdText would cause
  24.         My_StdText to be reentered, and would also mess up the pen
  25.         location. Therefore we create a scratch GrafPort.
  26.     */
  27.     GetPort( &save_port );
  28.     text_port = (GrafPtr) NewPtr( sizeof(GrafPort) );
  29.     if (text_port == NIL)
  30.         return;
  31.     OpenPort( text_port );
  32.     SetEmptyRgn( text_port->visRgn );
  33.     text_h = TEStylNew( &dest, &view );
  34.     SetPort( save_port );
  35.     
  36.     if (front->grafProcs == NIL)
  37.     {
  38.         if ((front->portBits.rowBytes & 0xC000) == 0xC000) // color GrafPort?
  39.         {
  40.             front->grafProcs = (QDProcs *) NewPtr( sizeof(CQDProcs) );
  41.             if (front->grafProcs == NIL)
  42.                 return;
  43.             SetStdCProcs( (CQDProcs *)front->grafProcs );
  44.         }
  45.         else
  46.         {
  47.             front->grafProcs = (QDProcs *) NewPtr( sizeof(QDProcs) );
  48.             if (front->grafProcs == NIL)
  49.                 return;
  50.             SetStdProcs( front->grafProcs );
  51.         }
  52.         got_grafProcs = true;
  53.     }
  54.     else
  55.         got_grafProcs = false;
  56.     Old_StdText = (pascal void (*)(short, Ptr, Point, Point))
  57.                     front->grafProcs->textProc;
  58.     front->grafProcs->textProc = (ProcPtr) My_StdText;
  59.     last_v = 0;
  60.     CKPT("Begin_copy end");
  61. }
  62.